package com.moxiao.yfjh.module.activity.dal.mysql.productType;

import java.util.*;

import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.module.activity.dal.dataobject.productType.ProductTypeDO;
import org.apache.ibatis.annotations.Mapper;
import com.moxiao.yfjh.module.activity.controller.admin.productType.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 相亲商品类型 Mapper
 *
 * @author mx
 */
@Mapper
public interface ProductTypeMapper extends BaseMapperX<ProductTypeDO> {

    default PageResult<ProductTypeDO> selectPage(ProductTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductTypeDO>()
                .eqIfPresent(ProductTypeDO::getNo, reqVO.getNo())
                .likeIfPresent(ProductTypeDO::getName, reqVO.getName())
                .eqIfPresent(ProductTypeDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ProductTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductTypeDO::getId));
    }

    default List<ProductTypeDO> selectList(ProductTypeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProductTypeDO>()
                .eqIfPresent(ProductTypeDO::getNo, reqVO.getNo())
                .likeIfPresent(ProductTypeDO::getName, reqVO.getName())
                .eqIfPresent(ProductTypeDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ProductTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductTypeDO::getId));
    }

    @Select("select count(*) num from blind_product_type where no = #{productTypeNo}")
    Integer getProductTypeNo(@Param("productTypeNo") String productTypeNo);

}
